package com.lnsf.bookstore.system.advPosition.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lnsf.bookstore.common.util.StringUtil;
import com.lnsf.bookstore.system.advPosition.dao.AdvPositionMapper;
import com.lnsf.bookstore.system.advPosition.service.AdvPositionService;
import com.lnsf.bookstore.system.advPosition.vo.AdvPosition;
import com.lnsf.bookstore.system.book.vo.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AdvPositionServiceImpl implements AdvPositionService {

    @Autowired
    private AdvPositionMapper advPositionMapper;

    @Override
    public PageInfo<AdvPosition> selectAll(Map<String, Object> map, AdvPosition advPosition) {
        if(StringUtil.getStringVal(map.get("page"))!= "" && StringUtil.getStringVal(map.get("limit"))!= "" ) {
            PageHelper.startPage(Integer.parseInt(map.get("page").toString()), Integer.parseInt(map.get("limit").toString()));
        }
        return new PageInfo<AdvPosition>(advPositionMapper.selectAll());
    }

    @Override
    public AdvPosition queryObject(Integer id) {
        return advPositionMapper.selectByPrimaryKey(id);
    }

    @Override
    public int deleteBatch(Integer[] ids) {
        return 0;
    }

    @Override
    public int update(AdvPosition advPosition) {
        return advPositionMapper.updateByPrimaryKeySelective(advPosition);
    }

    @Override
    public int save(AdvPosition advPosition) {
        return advPositionMapper.insertSelective(advPosition);
    }


}
